package com.zh.stargraph2.core.advice;

import com.zh.stargraph2.core.dto.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class CommonExceptionAdvice {


    @ExceptionHandler({Exception.class})
    public ResponseEntity commonException(Exception e) {
        log.error("请求异常", e);
        return ResponseEntity.status(HttpStatus.OK.value()).body(Result.error(e.getLocalizedMessage()));
    }
}
